package com.echo.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.echo.entity.pojo.Topic;
import com.echo.entity.vo.TopicListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/***
 * @date   2021/8/2 0002 15:16
 * @author JackeyTower
 */
@Mapper
@Repository
public interface TopicDAO extends BaseMapper<Topic> {

    @Update("update topic set content=#{content} where id=#{id}")
    public void updateTopicByCreator(@Param("id") int id,@Param("content") String content);

    @Select("select * from topic")
    public List<TopicListVO> selectTopicListVO();

    @Update("update topic set likes=likes+1 where id=#{tid} ")
    public void riseLikesForTopic(@Param("tid") String topicId);
}
